class Solution {
public:
    string reverseWords(string s) 
    {
        stringstream ss;                 //字符串流
        string ans = "", temp;       //临时变量

        ss << s;
        
        while(ss >> temp)
        {
            ans = " " + temp + ans;
        }

        if(ans != "")
            ans.erase(ans.begin());//删除第一个空格
        return ans;

    }
};